?><?
class cls_filter_typo extends cls_filter{
	var $saved = array();
	var $tags	 = 0;
  function process_html($object,$html){
    $html=preg_replace_callback("|\<script(.*?)>(.*?)</script>|i",array($this,"collect_scripts"),$html);
    if(getPHPVer()>=5){
      include_once("grape/lib/typograf.php");
      $typograf=new Typograf();
      $html=$typograf->execute($html,TYPOGRAF_MODE_NAMES,"windows-1251");
    }
		foreach($this->saved as $index=>$replace){
      $html = str_replace("%%TAG(".$index.")%%",$replace,$html);
		}
		return $html;
	}

	function collect_scripts($matches){
		$this->saved[]=$matches[0];
	  return "%%TAG(".(count($this->saved)-1).")%%";
	}
}
$filters[]="cls_filter_typo";
